﻿<UserControl x:Class="Supremacy.Client.Views.ColonyPlanetaryBuildQueueView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:s="http://schemas.startreksupremacy.com/xaml/core"
             xmlns:scc="http://schemas.startreksupremacy.com/xaml/presentation">
  <UserControl.Resources>
    <DataTemplate x:Key="BuildQueueListItemTemplate">
      <Border Padding="0,3,0,3">
        <Grid x:Name="ItemGrid">
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
          </Grid.ColumnDefinitions>
          <Grid.ToolTip>
            <ToolTip>
              <ContentControl Style="{DynamicResource TechObjectInfoPanelStyle}"
                              FontSize="12">
                <ContentControl.Content>
                  <scc:TechObjectDesignViewModel Design="{Binding Path=(s:BuildQueueItem.Project).(s:BuildProject.BuildDesign)}"
                                                 Location="{Binding Path=(s:BuildQueueItem.Project).(s:BuildProject.Location)}"
                                                 Civilization="{Binding Path=(s:BuildQueueItem.Project).(s:BuildProject.Builder)}" />
                </ContentControl.Content>
              </ContentControl>
            </ToolTip>
          </Grid.ToolTip>
          <Border x:Name="ImageBorder"
                  Grid.Column="0"
                  BorderBrush="White"
                  BorderThickness="1"
                  CornerRadius="4"
                  Width="40"
                  Height="40"
                  VerticalAlignment="Top">
            <Border.Background>
              <ImageBrush Stretch="UniformToFill"
                          ImageSource="{Binding Path=Project.BuildDesign.Image, Converter={StaticResource TechObjectImageConverter}}" />
            </Border.Background>
          </Border>
          <TextBlock x:Name="TextArea"
                     Grid.Column="1"
                     TextWrapping="Wrap"
                     VerticalAlignment="Top"
                     Margin="7,0,0,0"
                     TextTrimming="CharacterEllipsis"
                     FontFamily="{StaticResource {x:Static scc:ClientResources.HeaderFontFamilyKey}}"
                     FontSize="14pt">
            <TextBlock Foreground="{StaticResource {x:Static scc:ClientResources.HeaderTextForegroundBrushKey}}"
                       TextWrapping="Wrap"
                       Text="{Binding Path=Description, Converter={StaticResource UpperCaseConverter}}" />
            <LineBreak />
            <TextBlock Foreground="{StaticResource {x:Static scc:ClientResources.DefaultTextForegroundBrushKey}}">
              <TextBlock Text="{Binding Path=Project.TurnsRemaining}" />
              <TextBlock x:Name="TurnsText"
                         Text="{s:StringResource Key=BUILD_QUEUE_TURNS_REMAINING, Case=Upper}" />
            </TextBlock>
          </TextBlock>
        </Grid>
      </Border>
      <DataTemplate.Triggers>
        <DataTrigger Binding="{Binding Path=Project.TurnsRemaining}"
                     Value="1">
          <Setter TargetName="TurnsText"
                  Property="Text"
                  Value="{s:StringResource Key=BUILD_QUEUE_TURN_REMAINING, Case=Upper}" />
        </DataTrigger>
        <DataTrigger Binding="{Binding}"
                     Value="{x:Null}">
          <Setter TargetName="TextArea"
                  Property="Visibility"
                  Value="Hidden" />
          <Setter TargetName="ItemGrid" 
                  Property="ToolTip"
                  Value="{x:Null}" />
        </DataTrigger>
      </DataTemplate.Triggers>
    </DataTemplate>
  </UserControl.Resources>
  <DockPanel>
    <ContentControl MouseLeftButtonDown="OnCurrentBuildProjectClicked"
                    DataContext="{Binding Path=SelectedColony.BuildSlots[0], Mode=OneWay}"
                    Margin="1,3,0,3"
                    DockPanel.Dock="Top">
      <ContentControl.Template>
        <ControlTemplate>
          <StackPanel x:Name="CurrentBuildProjectPanel"
                      Orientation="Vertical"
                      Margin="0,0,0,7">
            <StackPanel.ToolTip>
              <ToolTip>
                <ContentControl Style="{DynamicResource TechObjectInfoPanelStyle}"
                                FontSize="12">
                  <ContentControl.Content>
                    <scc:TechObjectDesignViewModel Design="{Binding Path=(s:BuildSlot.Project).(s:BuildProject.BuildDesign)}"
                                                   Location="{Binding Path=(s:BuildSlot.Project).(s:BuildProject.Location)}"
                                                   Civilization="{Binding Path=(s:BuildSlot.Project).(s:BuildProject.Builder)}" />
                  </ContentControl.Content>
                </ContentControl>
              </ToolTip>
            </StackPanel.ToolTip>
            <TextBlock FontSize="18pt"
                       Margin="0,0,0,7"
                       FontFamily="{StaticResource {x:Static scc:ClientResources.HeaderFontFamilyKey}}"
                       Foreground="{StaticResource {x:Static scc:ClientResources.HeaderTextForegroundBrushKey}}"
                       Text="{s:StringResource Key=NOW_BUILDING, Case=Upper}" />
            <Grid>
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
              </Grid.ColumnDefinitions>
              <Border x:Name="ImageBorder"
                      Grid.Column="0"
                      BorderBrush="White"
                      BorderThickness="1"
                      CornerRadius="4"
                      Width="40"
                      Height="40"
                      VerticalAlignment="Top">
                <Border.Background>
                  <ImageBrush Stretch="UniformToFill"
                              ImageSource="{Binding Path=Project.BuildDesign.Image, Converter={StaticResource TechObjectImageConverter}}" />
                </Border.Background>
              </Border>
              <TextBlock x:Name="TextArea"
                         Grid.Column="1"
                         TextWrapping="Wrap"
                         VerticalAlignment="Top"
                         Margin="7,0,0,0"
                         TextTrimming="CharacterEllipsis"
                         FontFamily="{StaticResource {x:Static scc:ClientResources.HeaderFontFamilyKey}}"
                         FontSize="14pt">
                <TextBlock x:Name="DescriptionText"
                           Foreground="{StaticResource {x:Static scc:ClientResources.HeaderTextForegroundBrushKey}}"
                           TextTrimming="CharacterEllipsis"
                           TextWrapping="Wrap"
                           Text="{Binding Path=Project.Description, Converter={StaticResource UpperCaseConverter}}" />
                <LineBreak />
                <TextBlock x:Name="TimeText"
                           Foreground="{StaticResource {x:Static scc:ClientResources.DefaultTextForegroundBrushKey}}">
                  <TextBlock Text="{Binding Path=Project.PercentComplete}" />
                  <TextBlock Text="/" />
                  <TextBlock Text="{Binding Path=Project.TurnsRemaining}" />
                  <TextBlock x:Name="TurnsText"
                             Text="{s:StringResource Key=BUILD_QUEUE_TURNS_REMAINING, Case=Upper}" />
                </TextBlock>
              </TextBlock>
            </Grid>
            <Rectangle Height="7"
                       Margin="0,14,0,0"
                       Fill="{DynamicResource SeparatorBackgroundBrush}" />
          </StackPanel>
          <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding Path=Project.TurnsRemaining}"
                         Value="1">
              <Setter TargetName="TurnsText"
                      Property="Text"
                      Value="{s:StringResource Key=BUILD_QUEUE_TURN_REMAINING, Case=Upper}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=Project}"
                         Value="{x:Null}">
              <Setter TargetName="CurrentBuildProjectPanel"
                      Property="ToolTip"
                      Value="{x:Null}" />
              <Setter TargetName="DescriptionText"
                      Property="Text"
                      Value="{s:StringResource Key=BUILDING_NOTHING, Case=Upper}" />
              <Setter TargetName="TimeText"
                      Property="Visibility"
                      Value="Hidden" />
            </DataTrigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </ContentControl.Template>
    </ContentControl>
    <ScrollViewer DockPanel.Dock="Bottom">
      <s:HoverItemsControl x:Name="BuildQueue"
                           ItemClicked="OnBuildQueueItemClicked"
                           ItemsSource="{Binding Path=SelectedColony.BuildQueue}"
                           ItemTemplate="{StaticResource BuildQueueListItemTemplate}"
                           HorizontalContentAlignment="Stretch" />
    </ScrollViewer>
  </DockPanel>

</UserControl>
